﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Text;
//using System.Web.Mail;
using System.Net.Mail;
using System.Net;
namespace ReconUI
{
    public class Utils
    {
        public static string logPath = "";
        public static void logMessage(string msg, string path)
        {

            //FileStream stream = new FileStream(new File()
            StreamWriter writer = new StreamWriter(path + @"\log.txt", true);
            writer.Write(msg);
            writer.Close();
            writer.Dispose();
        }
        public static void sendEmail(string body, string subject, string to)
        {
            try
            {

                string from = "mapp123.world@4circlesolutions.com";
                MailMessage mailMsg = new MailMessage();
                mailMsg.From = new MailAddress(from);
                mailMsg.To.Add(to);
                mailMsg.Subject = subject;
                mailMsg.IsBodyHtml = false;
                mailMsg.BodyEncoding = Encoding.UTF8;
                mailMsg.Body = body;
                mailMsg.Priority = MailPriority.Normal;


                SmtpClient client = new SmtpClient();
                client.UseDefaultCredentials = false;
                //  client.Credentials = new NetworkCredential("mapp123.world@gmail.com", "");
                client.Credentials = new NetworkCredential("mapp123.world@4circlesolutions.com", "radhe123");
                // client.Host = "smtp.gmail.com";//for gmail "smtp.gmail.com";
                client.Host = "4circlesolutions.com";//for gmail "smtp.gmail.com";
                client.Port = 587; //use 465 or 587 for gmail  
                // client.EnableSsl = true;
                client.EnableSsl = false;
                client.DeliveryMethod = SmtpDeliveryMethod.Network;
                client.Send(mailMsg);


                mailMsg = null;
            }
            catch (Exception ex)
            {
                logMessage(ex.ToString(),"D:/RMD/Projects/VS_NETWork/ReconEngine_28Aug/ReconEngine_03OCT_Radhe/ReconUI");
            }
        }

    }
}